using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Unit_CollisionType_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Unit.CollisionType);

            field = type.GetField("None", flag);
            app.RegisterCLRFieldGetter(field, get_None_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_None_0, null);
            field = type.GetField("Cricle", flag);
            app.RegisterCLRFieldGetter(field, get_Cricle_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_Cricle_1, null);
            field = type.GetField("Pollygon", flag);
            app.RegisterCLRFieldGetter(field, get_Pollygon_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_Pollygon_2, null);
            field = type.GetField("Line", flag);
            app.RegisterCLRFieldGetter(field, get_Line_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_Line_3, null);
            field = type.GetField("Dot", flag);
            app.RegisterCLRFieldGetter(field, get_Dot_4);
            app.RegisterCLRFieldBinding(field, CopyToStack_Dot_4, null);
            field = type.GetField("Capsules", flag);
            app.RegisterCLRFieldGetter(field, get_Capsules_5);
            app.RegisterCLRFieldBinding(field, CopyToStack_Capsules_5, null);


            app.RegisterCLRCreateDefaultInstance(type, () => new huqiang.Unit.CollisionType());
            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Unit.CollisionType[s]);


        }

        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref huqiang.Unit.CollisionType instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch(ptr_of_this_method->ObjectType)
            {
                case ObjectTypes.Object:
                    {
                        __mStack[ptr_of_this_method->Value] = instance_of_this_method;
                    }
                    break;
                case ObjectTypes.FieldReference:
                    {
                        var ___obj = __mStack[ptr_of_this_method->Value];
                        if(___obj is ILTypeInstance)
                        {
                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            var t = __domain.GetType(___obj.GetType()) as CLRType;
                            t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                        }
                    }
                    break;
                case ObjectTypes.StaticFieldReference:
                    {
                        var t = __domain.GetType(ptr_of_this_method->Value);
                        if(t is ILType)
                        {
                            ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                        }
                    }
                    break;
                 case ObjectTypes.ArrayReference:
                    {
                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as huqiang.Unit.CollisionType[];
                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
                    }
                    break;
            }
        }


        static object get_None_0(ref object o)
        {
            return huqiang.Unit.CollisionType.None;
        }

        static StackObject* CopyToStack_None_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.CollisionType.None;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Cricle_1(ref object o)
        {
            return huqiang.Unit.CollisionType.Cricle;
        }

        static StackObject* CopyToStack_Cricle_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.CollisionType.Cricle;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Pollygon_2(ref object o)
        {
            return huqiang.Unit.CollisionType.Pollygon;
        }

        static StackObject* CopyToStack_Pollygon_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.CollisionType.Pollygon;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Line_3(ref object o)
        {
            return huqiang.Unit.CollisionType.Line;
        }

        static StackObject* CopyToStack_Line_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.CollisionType.Line;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Dot_4(ref object o)
        {
            return huqiang.Unit.CollisionType.Dot;
        }

        static StackObject* CopyToStack_Dot_4(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.CollisionType.Dot;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Capsules_5(ref object o)
        {
            return huqiang.Unit.CollisionType.Capsules;
        }

        static StackObject* CopyToStack_Capsules_5(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.CollisionType.Capsules;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


        static object PerformMemberwiseClone(ref object o)
        {
            var ins = new huqiang.Unit.CollisionType();
            ins = (huqiang.Unit.CollisionType)o;
            return ins;
        }


    }
}
